<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>toogel切换</title>
  <script src="vue.js"></script>
</head>
<body>
<!--toogel切换-->
<div id="app">
    <child-one v-if="type==='child-one'"></child-one>
    <child-two v-if="type==='child-two'"></child-two>
    <button @click="handelBtnClick">change</button>
</div>
<script>
  Vue.component('child-one',{
     template:'<div>' +
                      '<div>child-one</div>'+
              '</div>'
  })
  Vue.component('child-two',{
     template:'<div>' +
                      '<div>child-two</div>'+
              '</div>'
  })
  var vm=new Vue({
    el:"#app",
    data:{
      type:'child-one'
    },
    methods:{
      handelBtnClick:function(){
         this.type=(this.type==='child-one'?'child-two':'child-one');
      }
    }
  })
</script>
</body>
</html>
